package com.guge.sports.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.guge.sports.entity.Dto.DeptRunDetailDto;
import com.guge.sports.entity.Dto.RunningDetailsDataDto;
import com.guge.sports.entity.Dto.SchoolRunDetailDto;
import com.guge.sports.entity.RunSum;
import com.guge.sports.service.RunSumService;
import com.guge.sports.toolPackage.base.BaseController;
import com.guge.sports.utils.R;
import com.guge.sports.entity.Dto.StudentRunningDataDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;


/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author testjava
 * @since 2022-09-14
 */
@Api(description = "跑步汇总接口")
@RestController
@RequestMapping("/sports/run-sum")
public class RunSumController extends BaseController<RunSum> {

    @Autowired
    private RunSumService  runSumService;

    /**
     * 学校下学院跑步情况
     * @param deptRunDetailDto
     * @return
     */
    @ApiOperation(value = "各学校下学院的跑步情况")
    @PostMapping("/schoolRunDetails")
    public R getSchoolRunDetails(@RequestBody(required = false) DeptRunDetailDto deptRunDetailDto){
        System.out.println(deptRunDetailDto);
        List<SchoolRunDetailDto> schoolRunDetails = runSumService.getSchoolRunDetails(deptRunDetailDto);

        return R.ok().data("schoolRunDetails", schoolRunDetails);
    }

    /*
     *
     *  跑步管理 学生数据  Page 分页 数据  StudentRunningDataVo 条件查询
     * */
    @ApiOperation(value = "跑步管理实际分页查询")
    @RequestMapping("/RunningData/list/{current}/{size}")
    public R RunningDataPage(@RequestBody StudentRunningDataDto studentRunningDataDto,@PathVariable("current") Long current ,@PathVariable("size") Long size) {
        Page<StudentRunningDataDto> objectPage = new Page<>(current, size);
        return R.ok().data("page",runSumService.StudentRunningDataList(objectPage, studentRunningDataDto));
    }



    /*
     *
     *  跑步细节 学生数据  Page 分页 数据  StudentRunningDataVo 条件查询
     * */
    @ApiOperation(value = "跑步细节实际分页查询")
    @RequestMapping("/RunningDetails/list/{current}/{size}")
    public R RunningDataPage(@RequestBody RunningDetailsDataDto runningDetailsDataDto, @PathVariable("current") Long current , @PathVariable("size") Long size) {
        Page<RunningDetailsDataDto> objectPage = new Page<>(current, size);
        return R.ok().data("page",runSumService.RunningDetailsDataList(objectPage, runningDetailsDataDto));
    }


}

